<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>超市账单管理系统-用户管理</title>
<link type="text/css" rel="stylesheet"
	href="${pageContext.request.contextPath }/css/style.css">
 <script type="text/javascript">
   function page_num(frm,num){
	   //获取第几页
	   frm.pageIndex.value=num;
	   //表单提交
	   frm.submit();
   }
 </script>
 <style type="text/css">
  a,#page{
     font-size:25px;
     color:black;
     text-decoration:none;
     text-align:center;
  }
  #rew{
   background:gray;
  }
  a:hover{
   color:red;
  }
 </style>
</head>
<body>
	<div class="menu">
<input type="hidden" id="path" name="path" value="${pageContext.request.contextPath }"/>
<center>
		<table>
			<tbody>
				<tr>
					<td>
						
						<form method="post" action="${pageContext.request.contextPath }/user.do">
							<input name="method" value="query" class="input-text"
								type="hidden"> 
							<input name="pageIndex" value="1" class="input-text"
								type="hidden"> 
								输入用户名：<input name="queryname"
								class="input-text" type="text" value="${queryUserName }">&nbsp;&nbsp;&nbsp;&nbsp;
							<input id="cha" value="查 询" type="submit">
						</form>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
		</center>
	<center>
	<div class="main">

		<div class="optitle clearfix">
				<c:if test="${sessionScope.userSession.userType==1||sessionScope.userSession.userType==2}">
			<em><input value="添加用户" class="input-button"
				onclick="window.location='${pageContext.request.contextPath }/jsp/useradd.jsp'" type="button"> </em></c:if>
			<div class="title">用户管理<div id="mess">${message }</div></div>
		</div>
		<div class="content">
			<table class="list">
				<tbody>
					<tr id="rew">
						<td width="80"><div align="center">用户编码</div></td>
						<td width="80"><div align="center">用户名称</div></td>
						<td width="100"><div align="center">性别</div></td>
						<td width="100"><div align="center">年龄</div></td>
						<td width="100"><div align="center">电话</div></td>
						<td width="150"><div align="center">用户类型</div></td>
						<c:if test="${sessionScope.userSession.userType==1}">
						<td width="80"><div align="center">查看</div></td>
						<td width="80"><div align="center">修改</div></td>
						<td width="80"><div align="center">删除</div></td>
						</c:if>
					<c:if test="${sessionScope.userSession.userType==2||sessionScope.userSession.userType==3}">
					<td width="80"><div align="center">查看</div></td>
					</c:if>
					</tr>
					<c:forEach var="user" items="${userList}" varStatus="status">
						<tr>
							<td><span>${user.userCode}</span></td>
							<td><span>${user.userName}</span></td>
							<td><span> 
							<c:if test="${user.gender==1}">男</c:if> 
							<c:if test="${user.gender==2}">女</c:if> </span></td>
                            <td><span>${user.age }</span></td>
                            <td><span>${user.phone}</span></td>
                            <td><span><c:if test="${user.userType==1}">系统管理员</c:if>
                            <c:if test="${user.userType==2}">经理</c:if>
                            <c:if test="${user.userType==3}">普通员工</c:if>	
                            </span></td>
                             <c:if test="${sessionScope.userSession.userType==1 }">
                             <td>
                             <span>
                             <a class="viewUser" href="javascript:;" userid=${user.id } username=${user.userName }><img
				                   src="${pageContext.request.contextPath }/images/watch.png" /></a></span></td>
                           <td> <span><a class="modifyUser" href="javascript:;" userid=${user.id } username=${user.userName }><img
				                   src="${pageContext.request.contextPath }/images/add.jpg" /></a></span></td>
                            <td> <span><a class="deleteUser" href="javascript:;" userid=${user.id } username=${user.userName }><img
				                   src="${pageContext.request.contextPath }/images/del.jpg" /></a></span>
                             </td>
                             </c:if>
                                <c:if test="${sessionScope.userSession.userType==2 }">
                             <td>
                             <span><a class="viewUser" href="javascript:;" userid=${user.id } username=${user.userName }><img
				                   src="${pageContext.request.contextPath }/images/watch.png" /></a></span>
				                   </td>
				                   </c:if>
				                   <c:if test="${sessionScope.userSession.userType==3 }">
                             <td>
                             <span><a class="viewUser" href="javascript:;" userid=${user.id } username=${user.userName }><img
				                   src="${pageContext.request.contextPath }/images/watch.png" /></a></span>
				                   </td>
				                   </c:if>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
	</div>
		</center>
   <div id="page">
      <c:if test="${page.pageIndex>1}">
    <a href="javaScript:page_num(document.forms[0],1)">首页</a>
     <a href="javaScript:page_num(document.forms[0],${page.pageIndex-1})">上一页</a>
     </c:if>
     
      <c:if test="${page.pageIndex<page.pageCount}">
     <a href="javaScript:page_num(document.forms[0],${page.pageIndex+1})">下一页</a>
     <a href="javaScript:page_num(document.forms[0],${page.pageCount})">尾页</a>
     </c:if>
      第${page.pageIndex }页
   <c:if test="${page.pageCount<1 }">共1页</c:if>
      <c:if test="${page.pageCount>1 }">共${page.pageCount}页</c:if>
      共${page.counts }条数据
   </div>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/common.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/userlist.js"></script>
</body>
</html>